Prevent infinite loops in 3D track matching - #310
Open
jdkio wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Failure mechanism
Both matchers walk candidate hits backward using signed indices. When an out-of-bounds hit was encountered, the code unconditionally decremented the corresponding index and immediately continued. If that hit was at index zero, the index became
-1; thecontinuealso skipped the loop-condition update. Subsequent iterations then read outside the vector and could loop indefinitely, crash, or appear nondeterministic depending on the memory contents.This was observed in a mini-validation run of PR #301.
ConvertToTMSTree.exestayed at 100% CPU for more than 20 minutes after the final spill was sliced, versus about 200 seconds for the previous complete run. Repeated GDB samples all landed in the detector-bound checks inTrackMatching3D_XY()even though there were only two X candidates, two Y candidates, and eight hits in each current candidate. The matcher itself is unchanged by PR #301; that PR's changed hit population exposed this pre-existing bug.The fix stops matching when an out-of-bounds hit exhausts a required view, otherwise advances safely and updates the loop condition before continuing.
Similar-code audit
The U/V(/X) matcher contained the same unguarded decrement followed by
continue, so it is fixed here too. Other reverse-index loops inTMS_Reco.cppguard decrements withindex > 0or break immediately after reaching the boundary.Validation
git diff --checksrc/andapp/A full build/run is not available in the local VM because the experiment ROOT/CLHEP environment is not installed. The triggering full sample can be rerun in the FNAL environment.